package cn.gzsxt.dao.impl;

import java.util.List;

import cn.gzsxt.dao.ConstractDao;
import cn.gzsxt.po.Build;
import cn.gzsxt.po.Constract;
import cn.gzsxt.po.Floor;
import cn.gzsxt.po.Room;

public class ConstractDaoImpl extends BaseDaoImpl implements ConstractDao {

	@Override
	public List<Build> getBuild() {
		String sql = "select * from t_build";
		return super.selectListRow(Build.class, sql);
	}

	@Override
	public List<Floor> selectFloorByBuildId(Integer buildId) {
		String sql = "select * from t_floor where build_id = ?";
		return super.selectListRow(Floor.class, sql, buildId);
	}

	@Override
	public List<Room> selectRoomByFloorId(Integer floorId) {
		String sql = "select * from t_room where floor_id = ?";
		return super.selectListRow(Room.class, sql, floorId);
	}

	@Override
	public int insertConstract(Constract c) {
		String sql = "insert into t_constract(room_id,tenant_id,pcharge_id,purpose_id,signtime,starttime,endtime,monthfee,deposit,remarks)values"
				+ "(?,?,?,?,?,?,?,?,?,?)";
		Object[] params = {c.getRoom_id(),c.getTenant_id(),c.getPcharge_id(),c.getPurpose_id(),c.getSigntime(),
				c.getStarttime(),c.getEndtime(),c.getMonthfee(),c.getDeposit(),c.getRemarks()}; 
		return super.update(sql, params);
	}

	@Override
	public int updateRoomStatus(Integer room_id) {
		String sql = "update t_room set statustenant = 1 where id = ?";
		return super.update(sql, room_id);
	}

}
